Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom mode #12150

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open

Support custom mode #12150

wants to merge 1 commit into from

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Oct 7, 2024

Changes

Users can know pass custom --mode other than production and development, like staging or anything else etc.

Within Astro, how do we actually tell in we're in dev or prod state now?

For astro dev, it'll always be in the dev state. It's not possible to be in a prod state as it may break existing code, like HMR and stuff (which is also a restriction in Vite)

For astro build, it'll be prod state by default, unless the user passes --dev which Astro will then switch to a dev state.

In other parts of the codebase, there's also the concept of runtimeMode which contains this state as either "development" or "production" values only.

Future coding style

If we want to check the prod or dev state, we should no longer rely on mode as that's no longer relevant. We can check via these states instead:

  1. viteResolvedConfig.isProduction
  2. runtimeMode
  3. process.env.NODE_ENV === 'production'
  4. import.meta.env.PROD and import.meta.env.DEV

Testing

Added a new test to verify that it works.

Docs

TBA. The --dev flag will require docs.

Copy link

changeset-bot bot commented Oct 7, 2024

🦋 Changeset detected

Latest commit: c1cebb4

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr semver: minor Change triggers a `minor` release labels Oct 7, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant